<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      var subsets = function (nums) {
        const res = [];
        const track = [];
        backTrack(nums, 0);
        return res

        function backTrack(nums, n) {
          debugger
          res.push([...track]);
          for (let i = n; i < nums.length; i++) {
            track.push(nums[i]);
            backTrack(nums, i + 1);
            track.pop();
          }
        }
      };
      console.log(subsets([1, 2, 3]));
    </script>
  </body>
</html>
